<?php
namespace Home\Controller;
use Think\Controller;
class GooddetailController extends Controller {
    public function lists(){
		$id = $_GET['uid'];
		$res = M('listinfo')->where("id = $id")->find();
		$name = session('name');
		$this->assign('name',$name);
		$this->assign('res',$res);
		$this->assign("k",CONTROLLER_NAME);
		$this->assign("f",ACTION_NAME);
		$this->shop();
		//var_dump($res);
		$this->display();
    }
	public function shop(){
		$id = $_GET['id'];
		$title = $_POST['title'];
		$price = $_POST['price'];
		
		$shop = M('shoping')->select();
		foreach($shop as $k=>$v){
			$allid[]=$shop[$k]['p_id'];
		}
		//如果有相同id的商品就让number+1
		if(in_array($id, $allid)){
			//看$allid数组里是否存在ajax过来的id号
			$shop = M('shoping')->where("p_id = $id")->find();
			$data['number']=$shop['number']+1;
			M('shoping')->where("p_id = $id")->save($data);
		}else{
			$info = M('shoping')->add($data1);
		}
			
	}
}